package manager

import (
	"BlazeRider-backend/config"
	"strconv"
	"sync"
)

// manager/track_mem_storage.go
type trackMemStorage struct {
	tracks map[string]*TrackInfo
	mu     sync.RWMutex
}

func newTrackMemStorage() *trackMemStorage {
	return &trackMemStorage{
		tracks: make(map[string]*TrackInfo),
	}
}

// user_mem_storage.go补全方法
func (s *trackMemStorage) GetUserTrack(roomId string, userId string, times int) (*TrackInfo, bool) {
	s.mu.RLock()
	defer s.mu.RUnlock()
	key := config.Get().App.Env + roomId + userId + strconv.Itoa(times)
	//key := roomId + userId + strconv.Itoa(times)
	user, exists := s.tracks[key]
	return user, exists
}
